﻿@{
    Layout = null;
}

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>工艺选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/Common.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="gyCode" placeholder="工艺编码" autocomplete="off" class="layui-input" id="gyCode" style="width:150px;float:left">
                                <input type="text" name="gyName" placeholder="工艺名称" autocomplete="off" class="layui-input" id="gyName" style="width: 180px; float: left;margin-left:6px;margin-right:6px;">
                                @* <input type="hidden" name="plType" id="plType"> *@
                                <input type="hidden" name="relationCode" id="relationCode">
                                <button class="layui-btn" lay-filter="sreach" id="btnQuery" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                                <button class="layui-btn" lay-filter="sreach" id="btnSure" type="button" onclick="sureChoose()"><i class="layui-icon">&#xe679;</i>确认</button>
                            </div>


                        </form>
                    </div>

                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    var single = "1";
    var cData = new Array();
    var plType = "", relationCode = "";
    $(function () {
        single = getUrlVariable("isSingle");
        // plType = getUrlVariable("plType");
        relationCode = getUrlVariable("relationCode");
        // var tname = "scgy";
        // if (plType == "P-Pack") {
        //     tname="packgy";
        // }
        //getTableCloums(tname);
        // $("input[ name='plType']").val(plType);
        $("input[ name='relationCode']").val(relationCode);
        loadData();
    });
    /**
    加载数据
    **/
    function loadData() {
        var condition = JSON.stringify(FormToJson("qForm"));
        if (condition.includes("#")) {
            condition = condition.replace(/\#/g, "%23");
        }
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[
                      { type: 'checkbox' }
                    , { field: 'keyCode', title: '工艺编码', width: 150 }
                    , { field: 'gyName', title: '工艺名称', width: 140 }
                    , { field: 'relationName', title: '关联数据', width: 170 }
                    , { field: 'versionCode', title: '工艺版本', width: 100 }
                    , { field: 'memo', title: '备注说明', width: 130 }
                ]], done: function (res, curr, count) {
                    currPage = curr;
                    TablePowerHide();
                }
                , url: '../ProductSet/GetDataList?&dataType=proGyStandard&condition=' + condition  //数据接口
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
                , id: "list"

            })

            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;
                var checkStatus = table.checkStatus('list');
                var select = new Array();
                for (var i = 0; i < checkStatus.data.length; i++) {
                    select.push(checkStatus.data[i]);
                }
                cData = select;
            });

        });
    }
    //确认选择
    function sureChoose() {
        if (cData.length < 1) {
            layer.msg("您没有选择任何数据"); return;
        } else {
            if (single == "1" && cData.length > 1) {
                layer.msg("请选择一条数据"); return;
            } else {
                parent.getGYPar(cData); //这是父页面函数
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        }

    }
</script>
